package prototipo.test.easyaccept;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import prototipo.server.db.DBControllerPG;
import prototipo.server.db.exception.ExceptionDB;
import prototipo.server.logic.LogicFacade;
import prototipo.server.logic.exception.ExceptionLogic;
import prototipo.server.logic.item.Product;
import prototipo.server.logic.item.Raw;
import prototipo.server.logic.person.Client;
import prototipo.server.logic.person.ClientIF;
import prototipo.server.logic.person.Supplier;
import prototipo.server.logic.person.SupplierIF;
import prototipo.server.logic.transaction.Input;
import prototipo.server.logic.transaction.InputIF;
import prototipo.server.logic.transaction.ItemPay;
import prototipo.server.logic.transaction.ItemPayIF;
import prototipo.server.logic.transaction.Output;
import prototipo.server.logic.transaction.OutputIF;
import prototipo.server.logic.transaction.Payment;
import prototipo.server.logic.transaction.PaymentC;
import prototipo.server.logic.transaction.PaymentIF;
import prototipo.server.logic.transaction.PaymentP;
import prototipo.server.logic.transaction.PaymentV;
import prototipo.server.logic.user.RoleKind;
import prototipo.server.logic.user.User;
import prototipo.server.logic.util.Address;
import prototipo.server.logic.util.Cep;
import prototipo.server.logic.util.Cnpj;
import prototipo.server.logic.util.Cpf;
import prototipo.server.logic.util.Email;
import prototipo.server.logic.util.Money;
import prototipo.server.logic.util.Password;
import prototipo.server.logic.util.Phone;

public class EAFacade {

	private LogicFacade facade;

	public EAFacade() throws ExceptionDB {
		facade = new LogicFacade();
	}

	public int login(String login, String password) throws ExceptionLogic,
			ExceptionDB {
		Password pass = new Password(password);
		return facade.login(login, pass);
	}

	public boolean logout(int sessionID) throws ExceptionLogic {
		return facade.logout(sessionID);
	}

	public int registerUser(int sessionID, String newName, String newStreet,
			int newNumber, String newBlock, String newCep, String newCity,
			String newState, String newCountry, String newObservation,
			String ddiP, String dddP, String numberP, String ddiJ, String dddJ,
			String numberJ, String role, String newLogin, String password)
			throws ExceptionLogic, ExceptionDB {
		Address newAddress = new Address(newStreet, newNumber, newBlock,
				new Cep(newCep), newCity, newState, newCountry, newObservation);
		Phone newPhoneP = (numberP == null || numberP == "") ? null
				: new Phone(ddiP, dddP, numberP);
		Phone newPhoneJ = (numberJ == null || numberJ == "") ? null
				: new Phone(ddiJ, dddJ, numberJ);
		Password password2 = (password == null || password == "") ? null
				: new Password(password);
		User newUser = new User(newName, newAddress, newPhoneP, newPhoneJ,
				RoleKind.valueOf(role), newLogin, password2);
		return facade.registerUser(sessionID, newUser);
	}

	public boolean removeUser(int sessionID, int userID) throws ExceptionLogic,
			ExceptionDB {
		return facade.removeUser(sessionID, userID);
	}

	public boolean editUser(int sessionID, int userID, String newName,
			String newStreet, int newNumber, String newBlock, String newCep,
			String newCity, String newState, String newCountry,
			String newObservation, String ddiP, String dddP, String numberP,
			String ddiJ, String dddJ, String numberJ, String role,
			String newLogin, String password) throws ExceptionLogic,
			ExceptionDB {
		Address newAddress = new Address(newStreet, newNumber, newBlock,
				new Cep(newCep), newCity, newState, newCountry, newObservation);
		Phone newPhoneP = (numberP == null || numberP == "") ? null
				: new Phone(ddiP, dddP, numberP);
		Phone newPhoneJ = (numberJ == null || numberJ == "") ? null
				: new Phone(ddiJ, dddJ, numberJ);
		Password password2 = (password == null || password == "") ? null
				: new Password(password);
		User user = new User(newName, newAddress, newPhoneP, newPhoneJ,
				RoleKind.valueOf(role), newLogin, password2);
		return facade.editUser(sessionID, userID, user);
	}

	public long registerSupplier(int sessionID, String name, String street,
			int number, String block, String cep, String city, String state,
			String country, String observationAddress, String ddi, String ddd,
			String phone, String cnpj, String cpf, String email,
			String observation) throws ExceptionLogic, ExceptionDB {
		Address address = new Address(street, number, block, new Cep(cep),
				city, state, country, observationAddress);
		Phone phonep = (phone == null || phone == "") ? null : new Phone(ddi,
				ddd, phone);
		Cnpj cnpjj = (cnpj == null || cnpj == "") ? null : new Cnpj(cnpj);
		Cpf cpff = (cpf == null || cpf == "") ? null : new Cpf(cpf);
		Email emaill = (email == null || email == "") ? null : new Email(email);
		Supplier newSupplier = new Supplier(name, address, phonep, cnpjj, cpff,
				emaill, observation);
		return facade.registerSupplier(sessionID, newSupplier);
	}

	public boolean editSupplier(int sessionID, long supplierID, String name,
			String street, int number, String block, String cep, String city,
			String state, String country, String observationAddress,
			String ddi, String ddd, String phone, String cnpj, String cpf,
			String email, String observation) throws ExceptionLogic,
			ExceptionDB {
		Address address = new Address(street, number, block, new Cep(cep),
				city, state, country, observationAddress);
		Phone phonep = (phone == null || phone == "") ? null : new Phone(ddi,
				ddd, phone);
		Cnpj cnpjj = (cnpj == null || cnpj == "") ? null : new Cnpj(cnpj);
		Cpf cpff = (cpf == null || cpf == "") ? null : new Cpf(cpf);
		Email emaill = (email == null || email == "") ? null : new Email(email);
		Supplier editedSupplier = new Supplier(name, address, phonep, cnpjj,
				cpff, emaill, observation);
		return facade.editSupplier(sessionID, supplierID, editedSupplier);
	}

	public boolean removeSupplier(int sessionID, long supplierID)
			throws ExceptionLogic, ExceptionDB {
		return facade.removeSupplier(sessionID, supplierID);
	}

	public long registerClient(int sessionID, String name, String street,
			int number, String block, String cep, String city, String state,
			String country, String observationAddress, String ddi, String ddd,
			String phone, String cnpj, String cpf, String email, short route,
			String observation) throws ExceptionLogic, ExceptionDB {
		Address address = new Address(street, number, block, new Cep(cep),
				city, state, country, observationAddress);
		Phone phonep = (phone == null || phone == "") ? null : new Phone(ddi,
				ddd, phone);
		Cnpj cnpjj = (cnpj == null || cnpj == "") ? null : new Cnpj(cnpj);
		Cpf cpff = (cpf == null || cpf == "") ? null : new Cpf(cpf);
		Email emaill = (email == null || email == "") ? null : new Email(email);
		Client newClient = new Client(name, address, phonep, cnpjj, cpff,
				emaill, route, observation);
		return facade.registerClient(sessionID, newClient);
	}

	public boolean editClient(int sessionID, long clientID, String name,
			String street, Integer number, String block, String cep,
			String city, String state, String country,
			String observationAddress, String ddi, String ddd, String phone,
			String cnpj, String cpf, String email, Short route,
			String observation) throws ExceptionLogic, ExceptionDB {
		Address address = new Address(street, number, block, new Cep(cep),
				city, state, country, observationAddress);
		Phone phonep = (phone == null || phone == "") ? null : new Phone(ddi,
				ddd, phone);
		Cnpj cnpjj = (cnpj == null || cnpj == "") ? null : new Cnpj(cnpj);
		Cpf cpff = (cpf == null || cpf == "") ? null : new Cpf(cpf);
		Email emaill = (email == null || email == "") ? null : new Email(email);
		Client editedClient = new Client(name, address, phonep, cnpjj, cpff,
				emaill, route, observation);
		return facade.editClient(sessionID, clientID, editedClient);
	}

	public boolean removeClient(int sessionID, long clientID)
			throws ExceptionLogic, ExceptionDB {
		return facade.removeClient(sessionID, clientID);
	}

	public long registerRaw(int sessionID, String name, String measure,
			int amount, String description) throws ExceptionLogic, ExceptionDB {
		Raw newRaw = new Raw(name, description, amount, measure);
		return facade.registerRaw(sessionID, newRaw);
	}

	public int increaseRaw(int sessionID, int rawID, int quant)
			throws ExceptionLogic, ExceptionDB {
		return facade.increaseRaw(sessionID, rawID, quant);
	}

	public int decrementRaw(int sessionID, int rawID, int quant)
			throws ExceptionLogic, ExceptionDB {
		return facade.decrementRaw(sessionID, rawID, quant);
	}

	public boolean editRaw(int sessionID, int rawID, String name,
			String measure, int amount, String description) throws ExceptionDB,
			ExceptionLogic {
		Raw editedRaw = new Raw(name, description, amount, measure);
		return facade.editRaw(sessionID, rawID, editedRaw);
	}

	public boolean removeRaw(int sessionID, int rawID) throws ExceptionLogic,
			ExceptionDB {
		return facade.removeRaw(sessionID, rawID);
	}

	public long registerProduct(int sessionID, String name, String measure,
			int amount, String compositions, double priceVd, double priceCd,
			double pricePd, String description) throws ExceptionLogic,
			ExceptionDB {
		Money priceV = new Money(new BigDecimal(priceVd));
		Money priceC = new Money(new BigDecimal(priceVd));
		Money priceP = new Money(new BigDecimal(priceVd));
		Product newProduct = new Product(name, description, amount, measure,
				null, priceV, priceC, priceP);
		return facade.registerProduct(sessionID, newProduct);
	}

	public long registerProduct(int sessionID, String name, String measure,
			int amount, int comp1Item, short comp1Amount, int comp2Item,
			short comp2Amount, int comp3Item, short comp3Amount,
			double priceVd, double priceCd, double pricePd, String description)
			throws ExceptionLogic, ExceptionDB {
		Money priceV = new Money(new BigDecimal(priceVd));
		Money priceC = new Money(new BigDecimal(priceVd));
		Money priceP = new Money(new BigDecimal(priceVd));
		Map<Integer, Short> composition = new HashMap<Integer, Short>();
		composition.put(comp1Item, (short) comp1Amount);
		composition.put(comp2Item, (short) comp2Amount);
		composition.put(comp3Item, (short) comp3Amount);
		Product newProduct = new Product(name, description, amount, measure,
				composition, priceV, priceC, priceP);
		return facade.registerProduct(sessionID, newProduct);
	}

	public int increaseProduct(int sessionID, int productID, int quant)
			throws ExceptionLogic, ExceptionDB {
		return facade.increaseProduct(sessionID, productID, quant);
	}

	public int decrementProduct(int sessionID, int productID, int quant)
			throws ExceptionLogic, ExceptionDB {
		return facade.decrementProduct(sessionID, productID, quant);
	}

	public boolean editProduct(int sessionID, int productID, String name,
			String measure, int amount, String composition, double priceVd,
			double priceCd, double pricePd, String description)
			throws ExceptionLogic, ExceptionDB {
		Money priceV = new Money(new BigDecimal(priceVd));
		Money priceC = new Money(new BigDecimal(priceVd));
		Money priceP = new Money(new BigDecimal(priceVd));
		Product editedProduct = new Product(name, description, amount, measure,
				null, priceV, priceC, priceP);
		return facade.editProduct(sessionID, productID, editedProduct);
	}

	public boolean removeProduct(int sessionID, int productID)
			throws ExceptionLogic, ExceptionDB {
		return facade.removeProduct(sessionID, productID);
	}

	public long registerInput(int sessionID, long supplierID,
			String dataOficio, int iten1, int amount1, double price1,
			int iten2, int amount2, double price2, int iten3, int amount3,
			double price3, double pay1V, double pay2V, double pay3P,
			String pay3PSender, String pay3PDate, double pay4P,
			String pay4PSender, String pay4PDate, double pay5C,
			String pay5CSender, String pay5CBank, String pay5CDate,
			double pay6C, String pay6CSender, String pay6CBank, String pay6CDate)
			throws ExceptionLogic, ExceptionDB, ParseException {
		SupplierIF supplier = DBControllerPG.getInstance().getSupplierById(
				supplierID);
		Raw item1 = DBControllerPG.getInstance().getRawById(iten1);
		ItemPay itemP1 = new ItemPay(item1, amount1, new Money(new BigDecimal(
				price1)), false);
		Raw item2 = DBControllerPG.getInstance().getRawById(iten2);
		ItemPay itemP2 = new ItemPay(item2, amount2, new Money(new BigDecimal(
				price2)), false);
		Raw item3 = DBControllerPG.getInstance().getRawById(iten3);
		ItemPay itemP3 = new ItemPay(item3, amount3, new Money(new BigDecimal(
				price3)), false);
		List<ItemPayIF> listItens = new ArrayList<ItemPayIF>();
		listItens.add((ItemPayIF) itemP1);
		listItens.add((ItemPayIF) itemP2);
		listItens.add((ItemPayIF) itemP3);
		Payment pay1 = new PaymentV(new Money(new BigDecimal(pay1V)));
		Payment pay2 = new PaymentV(new Money(new BigDecimal(pay2V)));
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		GregorianCalendar pay3PDatee = new GregorianCalendar();
		pay3PDatee.setTime(dateFormat.parse(pay3PDate));
		Payment pay3 = new PaymentP(new Money(new BigDecimal(pay3P)),
				pay3PSender, pay3PDatee);
		GregorianCalendar pay4PDatee = new GregorianCalendar();
		pay4PDatee.setTime(dateFormat.parse(pay4PDate));
		Payment pay4 = new PaymentP(new Money(new BigDecimal(pay4P)),
				pay4PSender, pay4PDatee);
		GregorianCalendar pay5CDatee = new GregorianCalendar();
		pay5CDatee.setTime(dateFormat.parse(pay5CDate));
		Payment pay5 = new PaymentC(new Money(new BigDecimal(pay5C)),
				pay5CSender, pay5CBank, pay5CDatee);
		GregorianCalendar pay6CDatee = new GregorianCalendar();
		pay6CDatee.setTime(dateFormat.parse(pay6CDate));
		Payment pay6 = new PaymentC(new Money(new BigDecimal(pay6C)),
				pay6CSender, pay6CBank, pay6CDatee);
		List<PaymentIF> payments = new ArrayList<PaymentIF>();
		payments.add(pay1);
		payments.add(pay2);
		payments.add(pay3);
		payments.add(pay4);
		payments.add(pay5);
		payments.add(pay6);
		GregorianCalendar dateLatter = new GregorianCalendar();
		dateLatter.setTime(dateFormat.parse(dataOficio));
		InputIF input = new Input(supplier, dateLatter, listItens, payments);
		return facade.registerInput(sessionID, input);
	}

	public boolean editInput(int sessionID, long inputID, long supplierID,
			String dataOficio, int iten1, int amount1, double price1,
			int iten2, int amount2, double price2, int iten3, int amount3,
			double price3, double pay1V, double pay2V, double pay3P,
			String pay3PSender, String pay3PDate, double pay4P,
			String pay4PSender, String pay4PDate, double pay5C,
			String pay5CSender, String pay5CBank, String pay5CDate,
			double pay6C, String pay6CSender, String pay6CBank, String pay6CDate)
			throws ExceptionLogic, ExceptionDB, ParseException {
		SupplierIF supplier = DBControllerPG.getInstance().getSupplierById(
				supplierID);
		if (supplier == null)
			return false;
		Raw item1 = DBControllerPG.getInstance().getRawById(iten1);
		ItemPay itemP1 = new ItemPay(item1, amount1, new Money(new BigDecimal(
				price1)), false);
		Raw item2 = DBControllerPG.getInstance().getRawById(iten2);
		ItemPay itemP2 = new ItemPay(item2, amount2, new Money(new BigDecimal(
				price2)), false);
		Raw item3 = DBControllerPG.getInstance().getRawById(iten3);
		ItemPay itemP3 = new ItemPay(item3, amount3, new Money(new BigDecimal(
				price3)), false);
		List<ItemPayIF> listItens = new ArrayList<ItemPayIF>();
		listItens.add((ItemPayIF) itemP1);
		listItens.add((ItemPayIF) itemP2);
		listItens.add((ItemPayIF) itemP3);
		Payment pay1 = new PaymentV(new Money(new BigDecimal(pay1V)));
		Payment pay2 = new PaymentV(new Money(new BigDecimal(pay2V)));
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		GregorianCalendar pay3PDatee = new GregorianCalendar();
		pay3PDatee.setTime(dateFormat.parse(pay3PDate));
		Payment pay3 = new PaymentP(new Money(new BigDecimal(pay3P)),
				pay3PSender, pay3PDatee);
		GregorianCalendar pay4PDatee = new GregorianCalendar();
		pay4PDatee.setTime(dateFormat.parse(pay4PDate));
		Payment pay4 = new PaymentP(new Money(new BigDecimal(pay4P)),
				pay4PSender, pay4PDatee);
		GregorianCalendar pay5CDatee = new GregorianCalendar();
		pay5CDatee.setTime(dateFormat.parse(pay5CDate));
		Payment pay5 = new PaymentC(new Money(new BigDecimal(pay5C)),
				pay5CSender, pay5CBank, pay5CDatee);
		GregorianCalendar pay6CDatee = new GregorianCalendar();
		pay6CDatee.setTime(dateFormat.parse(pay6CDate));
		Payment pay6 = new PaymentC(new Money(new BigDecimal(pay6C)),
				pay6CSender, pay6CBank, pay6CDatee);
		List<PaymentIF> payments = new ArrayList<PaymentIF>();
		payments.add(pay1);
		payments.add(pay2);
		payments.add(pay3);
		payments.add(pay4);
		payments.add(pay5);
		payments.add(pay6);
		GregorianCalendar dateLatter = new GregorianCalendar();
		dateLatter.setTime(dateFormat.parse(dataOficio));
		InputIF editedInput = new Input(supplier, dateLatter, listItens,
				payments);
		return facade.editInput(sessionID, inputID, editedInput);
	}

	public boolean removeInput(int sessionID, long inputID)
			throws ExceptionLogic, ExceptionDB {
		return facade.removeInput(sessionID, inputID);
	}

	public long registerOutput(int sessionID, long clientID, long number,
			String dataOficio, int iten1, int amount1, double price1,
			int iten2, int amount2, double price2, int iten3, int amount3,
			double price3, double pay1V, double pay2V, double pay3P,
			String pay3PSender, String pay3PDate, double pay4P,
			String pay4PSender, String pay4PDate, double pay5C,
			String pay5CSender, String pay5CBank, String pay5CDate,
			double pay6C, String pay6CSender, String pay6CBank, String pay6CDate)
			throws ExceptionLogic, ExceptionDB, ParseException {
		ClientIF client = DBControllerPG.getInstance().getClientById(clientID);
		Product item1 = DBControllerPG.getInstance().getProductById(iten1);
		ItemPay itemP1 = new ItemPay(item1, amount1, new Money(new BigDecimal(
				price1)), false);
		Product item2 = DBControllerPG.getInstance().getProductById(iten2);
		ItemPay itemP2 = new ItemPay(item2, amount2, new Money(new BigDecimal(
				price2)), false);
		Product item3 = DBControllerPG.getInstance().getProductById(iten3);
		ItemPay itemP3 = new ItemPay(item3, amount3, new Money(new BigDecimal(
				price3)), false);
		List<ItemPayIF> listItens = new ArrayList<ItemPayIF>();
		listItens.add((ItemPayIF) itemP1);
		listItens.add((ItemPayIF) itemP2);
		listItens.add((ItemPayIF) itemP3);
		Payment pay1 = new PaymentV(new Money(new BigDecimal(pay1V)));
		Payment pay2 = new PaymentV(new Money(new BigDecimal(pay2V)));
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		GregorianCalendar pay3PDatee = new GregorianCalendar();
		pay3PDatee.setTime(dateFormat.parse(pay3PDate));
		Payment pay3 = new PaymentP(new Money(new BigDecimal(pay3P)),
				pay3PSender, pay3PDatee);
		GregorianCalendar pay4PDatee = new GregorianCalendar();
		pay4PDatee.setTime(dateFormat.parse(pay4PDate));
		Payment pay4 = new PaymentP(new Money(new BigDecimal(pay4P)),
				pay4PSender, pay4PDatee);
		GregorianCalendar pay5CDatee = new GregorianCalendar();
		pay5CDatee.setTime(dateFormat.parse(pay5CDate));
		Payment pay5 = new PaymentC(new Money(new BigDecimal(pay5C)),
				pay5CSender, pay5CBank, pay5CDatee);
		GregorianCalendar pay6CDatee = new GregorianCalendar();
		pay6CDatee.setTime(dateFormat.parse(pay6CDate));
		Payment pay6 = new PaymentC(new Money(new BigDecimal(pay6C)),
				pay6CSender, pay6CBank, pay6CDatee);
		List<PaymentIF> payments = new ArrayList<PaymentIF>();
		payments.add(pay1);
		payments.add(pay2);
		payments.add(pay3);
		payments.add(pay4);
		payments.add(pay5);
		payments.add(pay6);
		GregorianCalendar dateLatter = new GregorianCalendar();
		dateLatter.setTime(dateFormat.parse(dataOficio));
		OutputIF output = new Output(client, number, dateLatter, listItens,
				payments);
		return facade.registerOutput(sessionID, output);
	}

	public boolean editOutput(int sessionID, long outputID, long clientID,
			long number, String dataOficio, int iten1, int amount1,
			double price1, int iten2, int amount2, double price2, int iten3,
			int amount3, double price3, double pay1V, double pay2V,
			double pay3P, String pay3PSender, String pay3PDate, double pay4P,
			String pay4PSender, String pay4PDate, double pay5C,
			String pay5CSender, String pay5CBank, String pay5CDate,
			double pay6C, String pay6CSender, String pay6CBank, String pay6CDate)
			throws ExceptionLogic, ExceptionDB, ParseException {
		ClientIF client = DBControllerPG.getInstance().getClientById(clientID);
		if (client == null)
			return false;
		Product item1 = DBControllerPG.getInstance().getProductById(iten1);
		ItemPay itemP1 = new ItemPay(item1, amount1, new Money(new BigDecimal(
				price1)), false);
		Product item2 = DBControllerPG.getInstance().getProductById(iten2);
		ItemPay itemP2 = new ItemPay(item2, amount2, new Money(new BigDecimal(
				price2)), false);
		Product item3 = DBControllerPG.getInstance().getProductById(iten3);
		ItemPay itemP3 = new ItemPay(item3, amount3, new Money(new BigDecimal(
				price3)), false);
		List<ItemPayIF> listItens = new ArrayList<ItemPayIF>();
		listItens.add((ItemPayIF) itemP1);
		listItens.add((ItemPayIF) itemP2);
		listItens.add((ItemPayIF) itemP3);
		Payment pay1 = new PaymentV(new Money(new BigDecimal(pay1V)));
		Payment pay2 = new PaymentV(new Money(new BigDecimal(pay2V)));
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		GregorianCalendar pay3PDatee = new GregorianCalendar();
		pay3PDatee.setTime(dateFormat.parse(pay3PDate));
		Payment pay3 = new PaymentP(new Money(new BigDecimal(pay3P)),
				pay3PSender, pay3PDatee);
		GregorianCalendar pay4PDatee = new GregorianCalendar();
		pay4PDatee.setTime(dateFormat.parse(pay4PDate));
		Payment pay4 = new PaymentP(new Money(new BigDecimal(pay4P)),
				pay4PSender, pay4PDatee);
		GregorianCalendar pay5CDatee = new GregorianCalendar();
		pay5CDatee.setTime(dateFormat.parse(pay5CDate));
		Payment pay5 = new PaymentC(new Money(new BigDecimal(pay5C)),
				pay5CSender, pay5CBank, pay5CDatee);
		GregorianCalendar pay6CDatee = new GregorianCalendar();
		pay6CDatee.setTime(dateFormat.parse(pay6CDate));
		Payment pay6 = new PaymentC(new Money(new BigDecimal(pay6C)),
				pay6CSender, pay6CBank, pay6CDatee);
		List<PaymentIF> payments = new ArrayList<PaymentIF>();
		payments.add(pay1);
		payments.add(pay2);
		payments.add(pay3);
		payments.add(pay4);
		payments.add(pay5);
		payments.add(pay6);
		GregorianCalendar dateLatter = new GregorianCalendar();
		dateLatter.setTime(dateFormat.parse(dataOficio));
		OutputIF editedOutput = new Output(client, number, dateLatter,
				listItens, payments);
		return facade.editOutput(sessionID, outputID, editedOutput);
	}

	public boolean removeOutput(int sessionID, long outputID)
			throws ExceptionLogic, ExceptionDB {
		return facade.removeOutput(sessionID, outputID);
	}

	public boolean addPermission(int sessionID, int userID, String operation) throws ExceptionLogic, ExceptionDB {
		return facade.addPermission(sessionID, userID, operation);
	}

	public boolean removePermission(int sessionID, int userID, String operation) throws ExceptionLogic, ExceptionDB {
		return facade.removePermission(sessionID, userID, operation);
	}
}
